<template>
  <div id="cusInfo">
    <div class="cusInfo-content">
         <div class="cusInfo-content-box">
            <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="基本信息" name="first">
                    <div id="baseInfo">
                        <h3 class="baseInfo_title">筛选区</h3>
                        <el-form ref="form" :model="form" label-width="80px">
                            <el-form-item label="客户名称" prop="userName"
                            :rules="[{required:true,message:'请输入客户名称',trigger: 'blur'}]">
                                <el-input v-model="form.userName"></el-input>
                                <span class="item-tip-span">4-16个字符的数字、英文字母、下划线，中间不能有空格</span>
                            </el-form-item>
                            <el-form-item label="登录用户名" prop="loginName"
                            :rules="[{required:true,message:'请输入用户名',trigger: 'blur'}]">
                                <el-input v-model="form.loginName"></el-input>
                                <span class="item-tip-span">4-16个字符的数字、英文字母、下划线，中间不能有空格</span>
                            </el-form-item>
                            <el-form-item label="登录密码" prop="password"
                            :rules="[{required:true,message:'请输入登录密码',trigger: 'blur'}]">
                                <el-input type="password" v-model="form.password"></el-input>
                                <el-button type="primary" class="resetButton">重置</el-button>
                            </el-form-item>
                            <el-form-item label="账号从属">
                                <el-select v-model="form.userBelong" placeholder="请选择">
                                    <el-option v-for="item in belongList" :label="item.dictLabel" :value="item.id" :key="item.id"/>
                                </el-select>
                            </el-form-item>
                           <el-form-item prop="email" label="E-MAIL"
                                :rules="[
                                { required: true, message: '请输入邮箱地址', trigger: 'blur' },
                                { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
                                ]">
                                <el-input v-model="form.email"></el-input>
                            </el-form-item>
                            <el-form-item label="手机号码">
                                <el-input type="number" v-model="form.mobile"></el-input>
                            </el-form-item>
                            <el-form-item label="客户级别">
                                <el-select v-model="form.userLevel" placeholder="请选择">
                                    <el-option label="级别A" value="A"></el-option>
                                    <el-option label="级别B" value="B"></el-option>
                                    <el-option label="级别C" value="C"></el-option>
                                    <el-option label="级别D" value="D"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="有效期">
                                <el-date-picker
                                    v-model="form.validTime"
                                    type="daterange"
                                    range-separator="--"
                                    start-placeholder="开始日期"
                                    end-placeholder="结束日期">
                                </el-date-picker>
                            </el-form-item>
                            
                        </el-form>
        
                        <div class="groupBtn">
                          <el-button type="primary">取消</el-button>
                          <el-button type="danger" @click="onSubmit">保存</el-button>
                        </div>
                    </div>
                </el-tab-pane>
            </el-tabs>
         </div>
    </div>





  </div>
</template>

<script>
import '../assets/css/cusInfo.css'
export default {
  name: 'HelloWorld',
  data () {
    return {
        activeName: 'first',
        belongList: [],
        form: {
            loginName: '',
            userName:'',
            password: '',
            email: '',
            mobile: '',
            userBelong: '',
            userLevel: '',
            validTime: '',
            isFrontAcct: 1
        }
    }
  },
  mounted(){
    this.$Api.systemDict('sys_user_belong').then(({data}) => {
      this.belongList = data
    })
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    onSubmit() {
        this.$refs.form.validate(valid => {
            if (valid) {
                this.$Api.addSystemUser(this.form)
            } else {
                return false;
            }
        });
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
     handleCheckAllChange() {
      // this.checkedCities = val ? cityOptions : [];
      // this.isIndeterminate = false;
    },
    handleCheckedCitiesChange() {
      // let checkedCount = value.length;
      // this.checkAll = checkedCount === this.cities.length;
      // this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
    }
  },
  components:{
  }
}
</script>
<style>
/* #pageHome{
background: #ccc;
width:calc(100% - 200px);
} */

</style>
